$(function () {
    $(".submit—btn").click(function (e) {
        var old_psw = $("[name='old_psw']").val();
        var new_psw = $("[name='new_psw']").val();
        var re_new_psw = $("[name='re_new_psw']").val();
        if (new_psw.length < 6) {
            alert('密码不能小于6位!');
            return;
        }
        if (new_psw != re_new_psw) {
            alert('两次输入密码不一致!');
            return;
        }
        params = {
            'old_psw': old_psw,
            'new_psw': new_psw
        };
        $.ajax({
            url: "/user/update_psw",
            type: "post",
            data: JSON.stringify(params),
            contentType: "application/json"
        }).success(function (resp) {
            if (resp.errno == 0) {
                alert('修改成功，请重新登录!');
                location.href = '/passport/login'
            } else {
                alert(resp.errmsg)
            }
        }).error(function () {
            alert('网络异常')
        })
    });


});

